import request from "@/utils/request";
import { encryptedData } from "@/utils/encrypt";
import { loginRSA } from "@/config/settings";

export async function login(data) {
  if (loginRSA) {
    data = await encryptedData(data);
  }
  return request({
    url: "/sinohis/pension/login",
    method: "post",
    // headers: {
    //   "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    // },
    data,
  });
}

export function getUserInfo(accessToken) {
  return request({
    url: "/userInfo",
    method: "post",
    data: {
      accessToken,
    },
  });
}

export function getMenutree(accessToken) {
  return request({
    url: "/sinohis/pension/sys/resource/top/menutree",
    method: "get",
    data: {
      accessToken,
    },
  });
}

export function logout() {
  return request({
    url: "/logout",
    method: "post",
  });
}

export function search(params) {
  return request({
    url: "/sinohis/pension/sys/user",
    method: "get",
    params
  });
}
export function searchchild(params) {
  return request({
    url: "/sinohis/pension/sys/organization/searchOrganChilds/"+params.institutionNumber,
    method: "get",
    params
  });
}

export function dictionary(params) {
  return request({
    url: "/sinohis/pension/sys/dictionary/findAllDictionaryWithChild",
    method: "get",
    params
  });
}
export function register() {
  return request({
    url: "/register",
    method: "post",
  });
}

// 查询用户拥有非菜单资源权限
export function getButtonJurisdiction(params) {
  return request({
    url: "/sinohis/pension/sys/resource/top/othertree",
    method: "get",
    params
  });
}


// 查询用户拥有非菜单资源权限
export function searchUserOfOrgan(params) {
  return request({
    url: "/sinohis/pension/sys/user/all/organ",
    method: "get",
    params
  });
}

